{extend name="admin/base" /}
{block name="main"}
{if condition="$type == 'qq'"}
<div class="set-style">
	<dl>
		<dt>APP_KEY:</dt>
		<dd><input name="" id="APP_KEY" type="text" value="{$qq_config['value']['APP_KEY']}"/></dd>
	</dl>
	<dl>
		<dt>APP_SECRET:</dt>
		<dd><input name="" id="APP_SECRET" type="text" value="{$qq_config['value']['APP_SECRET']}"/></dd>
	</dl>
	<dl>
		<dt>是否启用:</dt>
		<dd>
				<input id="is_use" type="checkbox" class="checkbox" {if condition="$qq_config.is_use=='1'"}checked="checked"{/if}/>
		</dd>
	</dl>
	<dl>
		<dt>申请域名:</dt>
		<dd>{$qq_config['value']['AUTHORIZE']}</dd>
	</dl>
	<dl>
		<dt>回调域名:</dt>
		<dd>{$qq_config['value']['CALLBACK']}</dd>
	</dl>
	<input type = "hidden" id="AUTHORIZE" value="{$qq_config['value']['AUTHORIZE']}">	
	<input type = "hidden" id="CALLBACK" value="{$qq_config['value']['CALLBACK']}">
	<button class="edit_button" onclick="setConfigAjax();">提交</button>
</div>
<script>
	function setConfigAjax(){
		var appkey = $("#APP_KEY").val();
		var appsecret = $("#APP_SECRET").val();
		var url = $("#AUTHORIZE").val();
		var call_back_url = $("#CALLBACK").val();
		var is_use = 0;
		if($("#is_use").is(":checked")){
			is_use = 1;
		}
		$.ajax({
			type:"post",
			url:"ADMIN_MAIN/config/loginqqconfig",
			data:{
				'appkey':appkey,
				'appsecret':appsecret,
				'url':url,
				'call_back_url':call_back_url,
				"is_use" : is_use
			},
			success:function (data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"]);
				}else{
					showMessage('error', data["message"]);
				}	
			}
		});
	}
</script>
{else/}
<div class="set-style">
	<dl>
		<dt>APP_KEY:</dt>
		<dd><input name="" id="APP_KEY" type="text" value="{$wchat_config['value']['APP_KEY']}"/></dd>
	</dl>
	<dl>
		<dt>APP_SECRET:</dt>
		<dd><input name="" id="APP_SECRET" type="text" value="{$wchat_config['value']['APP_SECRET']}"/></dd>
	</dl>
	<dl>
		<dt>是否启用:</dt>
		<dd>
				<input id="is_use" type="checkbox" class="checkbox" {if condition="$wchat_config.is_use=='1'"}checked="checked"{/if}/>
		</dd>
	</dl>
	<dl>
		<dt>申请域名:</dt>
		<dd>{$wchat_config['value']['AUTHORIZE']}</dd>
	</dl>
	<dl>
		<dt>回调域名:</dt>
		<dd>{$wchat_config['value']['CALLBACK']}</dd>
	</dl>
	<input type = "hidden" id="AUTHORIZE" value="{$wchat_config['value']['AUTHORIZE']}">
	<input type = "hidden" id="CALLBACK" value="{$wchat_config['value']['CALLBACK']}">
	<button class="edit_button" onclick="setConfigAjax();">提交</button>
</div>
<script>
	function setConfigAjax(){
		var appkey = $("#APP_KEY").val();
		var appsecret = $("#APP_SECRET").val();
		var url = $("#AUTHORIZE").val();
		var call_back_url = $("#CALLBACK").val();
		var is_use = 0;
		if($("#is_use").is(":checked")){
			is_use = 1;
		}
		$.ajax({
			type:"post",
			url:"ADMIN_MAIN/config/loginweixinconfig",
			data:{
				'appkey':appkey,
				'appsecret':appsecret,
				'url':url,
				'call_back_url':call_back_url,
				"is_use" : is_use
			},
			success:function (data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],'ADMIN_MAIN/config/partylogin');
				}else{
					showMessage('error', data["message"]);
				}	
			}
		});
	}
</script>
{/if}
{/block}